package wangjg.dbfx.dialect;

public class OracleSQLPaging implements SQLPaging {

	public String getLimitString(String sql, int offset, int limit) {
		StringBuilder sb = new StringBuilder(sql.length()+105);
		sb.append("select * from ( select row_.*, rownum rownum_ from ( ");
		sb.append(sql);
		sb.append(" ) row_ where rownum <= "+(offset+limit)+") where rownum_ > "+offset);
		return sb.toString();
	}

	public static void main(String args[]){
		OracleSQLPaging p = new OracleSQLPaging();
		String s = p.getLimitString("select * from xxx where 1=1 order by a desc", 5, 10);
		System.out.println(s);
	}
}
